package com.gbiac.jeecgRPT.Controller;

import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.util.DynamicDBUtil;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.gbiac.jeecgRPT.service.WecharService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 微信报表controller
 * @author Administrator
 */
@Scope("prototype")
@Controller
@RequestMapping("/wecharReportController")
public class WecharReportController extends BaseController{
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(WecharReportController.class);
	/**
	 *  生产数据报表数据源
	 */
	private static final String DBKEY_productiveResource = "PR-DB";
	
	@Autowired
	private SystemService systemService;
	
	@Autowired
	private WecharService wecharService;
	
	@RequestMapping(params = "queryDate1")
	public void queryData1(HttpServletRequest request, HttpServletResponse response){
		JSONObject jsonObject = new JSONObject();
		JSONObject jsonObjectData = new JSONObject();
		String data1  = wecharService.queryData1();
		jsonObject.put("SUCCESS", "true");
		jsonObject.put("message", "true");
		jsonObjectData.put("queryData", data1);
		jsonObject.put("data",jsonObjectData);
		String data = jsonObject.toString();
		super.responseReturn(response, logger, data);
	}
	
	@RequestMapping(params = "queryDate2")
	public void queryData2(HttpServletRequest request, HttpServletResponse response){
		JSONObject jsonObject = new JSONObject();
		JSONObject jsonObjectData = new JSONObject();
		String dataIO  = wecharService.queryData2IO();
		String dataHXFL = wecharService.queryData2HXFL();
		String dataDLR = wecharService.queryData2DLR();
		jsonObject.put("SUCCESS", "true");
		jsonObject.put("message", "true");
		jsonObjectData.put("queryDataIO", dataIO);
		jsonObjectData.put("queryDataHXFL", dataHXFL);
		jsonObjectData.put("queryDataDLR", dataDLR);
		jsonObject.put("data",jsonObjectData);
		String data = jsonObject.toString();
		super.responseReturn(response, logger, data);
	}
	
	@RequestMapping(params = "queryDate3")
	public void queryData3(HttpServletRequest request, HttpServletResponse response){
		JSONObject jsonObject = new JSONObject();
		JSONObject jsonObjectData = new JSONObject();
		String data3 = wecharService.queryData3();
		jsonObjectData.put("queryData", data3);
		jsonObject.put("SUCCESS", "true");
		jsonObject.put("message", "true");
		jsonObject.put("data",jsonObjectData);
		String data = jsonObject.toString();
		super.responseReturn(response, logger, data);
	}
	
	@RequestMapping(params = "queryDate4")
	public void queryData4(HttpServletRequest request, HttpServletResponse response){
		JSONObject jsonObject = new JSONObject();
		JSONObject jsonObjectData = new JSONObject();
		String data4 = wecharService.queryData4();
		jsonObjectData.put("queryData", data4);
		jsonObject.put("SUCCESS", "true");
		jsonObject.put("message", "true");
		jsonObject.put("data",jsonObjectData);
		String data = jsonObject.toString();
		super.responseReturn(response, logger, data);
	}
	@RequestMapping(params = "airportData")
	public void airporData(String rq,HttpServletRequest request,HttpServletResponse response) {
		String json = wecharService.airportData(rq);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("queryData", json);
		jsonObject.put("SUCCESS", "true");
		jsonObject.put("message", "true");
		super.responseReturn(response, logger, jsonObject.toString());
	}
	@RequestMapping(params = "dayAirportData")
	public void dayAirportData(String rq,HttpServletRequest request,HttpServletResponse response) {
		String jsonString = wecharService.dayAirportData(rq);
		JSONArray json=JSONArray.fromObject(jsonString);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("queryData", json);
		jsonObject.put("SUCCESS", "true");
		jsonObject.put("message", "true");
		super.responseReturn(response, logger, jsonObject.toString());
	}
	@RequestMapping(params = "hotAirportData") 
	public void hotAirpotData(String rq,HttpServletRequest request,HttpServletResponse response) {
		String jsonString = wecharService.hotAirportData(rq);
		JSONArray jsonArray = JSONArray.fromObject(jsonString);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("queryData", jsonArray);
		jsonObject.put("SUCCESS", "true");
		jsonObject.put("message", "true");
		super.responseReturn(response, logger, jsonObject.toString());
	}
	@RequestMapping(params = "airportReportData")
	public void airportReportData(String rq,HttpServletRequest request,HttpServletResponse response) {
		String jsonString = wecharService.airportReportData(rq);
		JSONArray jsonArray = JSONArray.fromObject(jsonString);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("queryData", jsonArray);
		jsonObject.put("SUCCESS", "true");
		jsonObject.put("message", "true");
		super.responseReturn(response, logger, jsonObject.toString());
	}
	
}
